home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 22 / CU Amiga Magazine's Super CD-ROM 22 (1998)(EMAP Images)(GB)[!][issue 1998-05].iso / PowerPC / System / PPCReleaseDEV / Examples / callm68ksync.c next >
Encoding:
C/C++ Source or Header  |  1998-02-21  |  1.9 KB  |  88 lines

  1. #include <exec/types.h>
  2. #include <exec/nodes.h>
  3. #include <exec/lists.h>
  4. #include <exec/memory.h>
  5. #include <powerup/ppclib/interface.h>
  6. #include <powerup/gcclib/powerup_protos.h>
  7.  
  8. #define    TEXT    "This is a test\n"
  9.  
  10. UWORD    M68kProgram[]=
  11. {
  12. /*
  13. Color:
  14. ;d0=color
  15.     move.l    d2,-(a7)
  16.     moveq    #-1,d1
  17.     moveq    #20,d2
  18. 0$:
  19.     move.w    d0,$dff180
  20.     dbra    d1,0$
  21.     dbra    d2,0$
  22.     move.l    (a7)+,d2
  23.     rts
  24. */
  25.  
  26.   0x2f02,
  27.   0x72ff,
  28.   0x7414,
  29.   0x33c0,
  30.   0x00df,
  31.   0xf180,
  32.   0x51c9,
  33.   0xfff8,
  34.   0x51ca,
  35.   0xfff4,
  36.   0x241f,
  37.   0x4e75
  38. };
  39.  
  40.  
  41. int Function(APTR    Function)
  42. {
  43. BPTR    MyFile;
  44. struct Caos    *MyCaos;
  45. ULONG        DataArray[10];
  46.  
  47.   if (MyFile=PPCOpen("con:0/0/640/200/WindowOpenedByPPC/CLOSE",MODE_NEWFILE))
  48.   {
  49.     PPCWrite(MyFile,
  50.              TEXT,
  51.              strlen(TEXT));
  52.  
  53.     DataArray[0]    =    0x100;
  54.     DataArray[1]    =    (ULONG) PPCAllocVec(DataArray[0],MEMF_PUBLIC|MEMF_CLEAR);
  55.  
  56.     PPCRawDoFmt("Allocated %ld Bytes at Address 0x%lx\n",
  57.                 &DataArray,
  58.                 1,                /* 0=Buffer,1=serial <> NOT supported yet */
  59.                 NULL);
  60.  
  61.     if (MyCaos = (struct Caos*) PPCAllocVec(sizeof(struct Caos),MEMF_PUBLIC|MEMF_CLEAR))
  62.     {
  63.       MyCaos->caos_Un.Function    =    (APTR) &M68kProgram;
  64.       /* Look at the function above and you see that this
  65.          function doesn`t touch any memory the PPC uses too or
  66.          will use after the function returns.
  67.          BUT let`s assume you would call AllocMem now and pass back
  68.          that ptr to the PPC program you would need to set CacheFlush
  69.          TRUE. Attention..you`re aren`t allowed to use normal AllocMem
  70.          areas anyway because of the needed CacheLine Alignment only
  71.          the ppc.library functions offer.
  72.        */
  73.       MyCaos->M68kCacheMode    =    IF_CACHEFLUSHNO;
  74.       MyCaos->PPCCacheMode    =    IF_CACHEFLUSHNO;
  75.       MyCaos->d0        =    0x0ff;
  76.       PPCCallM68k(MyCaos);
  77.       PPCFreeVec(MyCaos);
  78.     }
  79.     if (DataArray[1])
  80.     {
  81.       PPCFreeVec((APTR) DataArray[1]);
  82.     }
  83.     PPCClose(MyFile);
  84.     return(1);
  85.   }
  86.   return(0);
  87. }
  88.